#include "UiCtrlWnd.h"
#ifdef MERGER_APP_TO_SHELL
	extern HINSTANCE g_SDHResModuleHandle;
#endif
UiCtrlWnd::UiCtrlWnd()
{
}

UiCtrlWnd::~UiCtrlWnd()
{
}

BOOL UiCtrlWnd::InitUiWin(void)
{
	BOOL bRtn = FALSE;
	LoadiInterItem();
	return bRtn;
}

void UiCtrlWnd::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	m_CtrlWndBG->Draw(hdc, prcWin, false, false);
}

int UiCtrlWnd::OnLButtonDown(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonDown(fwKeys, xPos, yPos);

}

int UiCtrlWnd::OnLButtonUp(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonUp(fwKeys, xPos, yPos);

}

void UiCtrlWnd::LoadiInterItem()
{
//jdhuang 20120818
	
#ifndef MERGER_APP_TO_SHELL
	m_CtrlWndBG = ImagingHelper::GetImageObject(MzGetInstanceHandle(), 1058);
#else
	m_CtrlWndBG = ImagingHelper::GetImageObject(g_SDHResModuleHandle, 5058);
#endif
	RECT rtBtnCtrlWnd[MAX_CTRL_WND_BTN] = 
	{
		0, 160, 85, 245,
		43, 8, 128, 93,
		99, 81, 184, 166,
		127, 166, 212, 251,
		99, 254, 184, 339,
		43, 329, 128, 414,
	};
	
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetPos(rtBtnCtrlWnd[CTRL_WND_DIAL_ON].left, rtBtnCtrlWnd[CTRL_WND_DIAL_ON].top,
					rtBtnCtrlWnd[CTRL_WND_DIAL_ON].right-rtBtnCtrlWnd[CTRL_WND_DIAL_ON].left,
					rtBtnCtrlWnd[CTRL_WND_DIAL_ON].bottom-rtBtnCtrlWnd[CTRL_WND_DIAL_ON].top);
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetID(2200);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1002, true));
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1003, true));
#else
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5002, true));
	m_BtnCtrlWnd[CTRL_WND_DIAL_ON].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5003, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_DIAL_ON]);

	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetPos(rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].left, rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].top,
					rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].right-rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].left,
					rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].bottom-rtBtnCtrlWnd[CTRL_WND_DIAL_PANEL].top);
	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetID(2201);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1004, true));
	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1005, true));
#else
	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5004, true));
	m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5005, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_DIAL_PANEL]);

	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetPos(rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].left, rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].top,
					rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].right-rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].left,
					rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].bottom-rtBtnCtrlWnd[CTRL_WND_PHONE_BOOK].top);
	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetID(2202);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1006, true));
	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1007, true));
#else
	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5006, true));
	m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5007, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_PHONE_BOOK]);

	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetPos(rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].left, rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].top,
					rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].right-rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].left,
					rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].bottom-rtBtnCtrlWnd[CTRL_WND_CALL_RECORD].top);
	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetID(2203);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1008, true));
	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1009, true));
#else
	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5008, true));
	m_BtnCtrlWnd[CTRL_WND_CALL_RECORD].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5009, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_CALL_RECORD]);

	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetPos(rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].left, rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].top,
					rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].right-rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].left,
					rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].bottom-rtBtnCtrlWnd[CTRL_WND_PAIR_RECORD].top);
	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetID(2204);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1010, true));
	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1011, true));
#else
	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5010, true));
	m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5011, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_PAIR_RECORD]);

	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetPos(rtBtnCtrlWnd[CTRL_WND_HANG_UP].left, rtBtnCtrlWnd[CTRL_WND_HANG_UP].top,
					rtBtnCtrlWnd[CTRL_WND_HANG_UP].right-rtBtnCtrlWnd[CTRL_WND_HANG_UP].left,
					rtBtnCtrlWnd[CTRL_WND_HANG_UP].bottom-rtBtnCtrlWnd[CTRL_WND_HANG_UP].top);
	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetID(2205);
#ifndef MERGER_APP_TO_SHELL
	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1012, true));
	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1013, true));
#else
	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5012, true));
	m_BtnCtrlWnd[CTRL_WND_HANG_UP].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5013, true));
#endif
	AddChild(&m_BtnCtrlWnd[CTRL_WND_HANG_UP]);
}

BOOL UiCtrlWnd::InitImages()
{
	return TRUE;
}
void UiCtrlWnd::DeleteImages()
{
	m_CtrlWndBG->UnloadImage();
}